package com.zijie;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Test3 {
	public static void main1(String[] args) {
		//IO中的流使用完后，一定要关闭来释放资源
		File f1 = new File("E:\\PR\\a.txt");
		InputStream in = null;
		try {
			in = new FileInputStream(f1);
			int len = 0;
			byte[] bs = new byte[777];
			while((len = in.read(bs)) > -1) {
				System.out.println(len+Arrays.toString(bs));
			}
		} catch (Exception e) {
			System.out.println("IO异常才处理");
			e.printStackTrace();
		}finally {
			try {
				in.close();
			} catch (IOException e) {
				
			}
		}
		
	}
	public static void main(String[] args) {
		//IO中的流使用完后，一定要关闭资源
		//JDK1.7+ 资源的自动释放
		//implements   
		/**
		 * in.txt
		 * ABC/abc 65, 66, 67, 13, 10, 97, 98, 99
		 */
		File f1 = new File("E:\\PR\\a.txt");
		try(
				InputStream in= new FileInputStream(f1);
				
				) {
			
			int len = 0;
			byte[] bs = new byte[777];
			while((len = in.read(bs)) > -1) {
				System.out.println(len+Arrays.toString(bs));
			}
		} catch (Exception e) {
			System.out.println("IO异常才处理");
			e.printStackTrace();
		}
	}
}
